package com.example.blog.service;

import com.example.blog.mapper.BlogMapper;
import com.example.blog.model.BlogInfo;
import com.example.blog.model.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BlogService {
    @Autowired
    private BlogMapper blogMapper;
    public List<BlogInfo> selectAll() {
        return blogMapper.selectAll();
    }

    public BlogInfo getBlogDetail(Integer blogId) {
        return blogMapper.selectById(blogId);
    }

    public BlogInfo selectById(Integer blogId) {
        BlogInfo blogInfo = blogMapper.selectById(blogId);
        if(blogInfo == null){
            return null;
        }
        return blogInfo;
    }

    public int insertBlog(BlogInfo blogInfo) {
        return blogMapper.insertBlog(blogInfo);
    }

    public int updateBlog(BlogInfo blogInfo) {
        return blogMapper.updateBlog(blogInfo);
    }
}
